import { useDispatch, useSelector } from "react-redux"
import { changeState, ASYNC_CHANGE } from '../app/slices/users'

export default function User() {

    const { users } = useSelector(state => state)
    const dispatch = useDispatch()

    return (
        <div>
            <p>{ users.msg }</p>
            <p>
                {/* <span>用户名称是{users.name}, 年龄是{users.age}</span> */}
                {users.name}
            </p>

            <button onClick={() => {
                dispatch(ASYNC_CHANGE('古力娜扎'))
            }}>修改</button>
        </div>
    )
}

// dispatch(changeState('古力娜扎'))
/*

            dispatch(changeState({
                    name: '古力娜扎',
                    age: 18
                }))

*/